
function severCheck() {
        var loginname = $("#loginname").val();
		var password = $("#password").val();
		if(loginname==""||password==""){
					$("#doc-vld-msg").submit();
					return false;
		 }	
		var id = "body-loading";
  		$(window).loading({action:"open",id:id,font:40}); 
		var code = "qqbigbug"+loginname+",zx,"+password;
		$.getJSON ("json/locat.json", function (data) {
			var  locat=data["url"];
			var factoryid=data["factoryid"];
	        $.ajax(locat+"/clientUser/login", {
	            type: "POST",
	            xhrFields: {
	                withCredentials: true,
	                useDefaultXhrHeader: false
	            },
	            data: {
	                KEYDATA: code,
	                factoryid: factoryid
	            },
	            crossDomain: true,
	            success: function(data, status, xhr) {
	            		var time = setTimeout(function(){
			   				//关闭
			   				$(window).loading({action:"close",id:id});
			   			},100);
			        	var cookie=  $.AMUI.utils.cookie;
			        	cookie.unset("sessionId");
			        	cookie.unset("factoryid");
			        	var time=new Date();
			        	time=new Date(time.valueOf() +2*60*1000);
			        	cookie.set("sessionId",data.sessionId,time,"/");
			        	cookie.set("factoryid",factoryid,time,"/");
						if("success" == data.result){
								saveCookie();
								window.location.href="user.html";
						}else if("usererror" == data.result){
								swal("用户名或密码错误");
								$("#loginname").focus();
						}else{	
								swal("缺少参数")
								$("#loginname").focus();
						}
	            },
	            error:function(data){
	            	swal("","服务异常","error");
	            }
	        });
    });  
}
 




function saveCookie() {
			if ($("#saveid").attr("checked")) {
				$.cookie('loginname', $("#loginname").val(), {
					expires : 7
				});
				$.cookie('password', $("#password").val(), {
					expires : 7
				});
			}
		}

jQuery(function() {
			var loginname = $.cookie('loginname');
			var password = $.cookie('password');
			if (typeof(loginname) != "undefined"
					&& typeof(password) != "undefined") {
				$("#loginname").val(loginname);
				$("#password").val(password);
				$("#saveid").attr("checked", true);
				$("#code").focus();
			}
		});
		
function savePaw() {
			if (!$("#saveid").attr("checked")) {
				$.cookie('loginname', '', {
					expires : -1
				});
				$.cookie('password', '', {
					expires : -1
				});
				$("#loginname").val('');
				$("#password").val('');
			}
		}


/*function logout(){
	var flag=true;
	swal({
		title: "您确定要退出吗？",
		text: "",
		type: "warning",
		showCancelButton: true,
		closeOnConfirm: true,
		cancelButtonText: "取消",
		confirmButtonText: "确定",
		confirmButtonColor: "#ec6c62"
	}, function() {
		flag=false;
		alert(flag);
	})
	alert(flag);
	if(flag)
		WeixinJSBridge.call('closeWindow');
}*/


function genTimestamp() {
			var time = new Date();
			return time.getTime();
		}